<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增优惠券</title>
    <link rel="stylesheet" href="../../lib/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../font/iconfont.css">
    <script src="../../lib/jquery/jquery-3.6.0.min.js"></script>
    <script src="../../lib/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>
    <!-- <script src="../../javaScript/renyuanshuju.js"></script>
    <script src="../../javaScript/fenYe.js"></script>
    <script src="../../javaScript/accountDetails.js"></script> -->
    <script src="../../javaScript/cuxiaoguanli/shuju.js"></script>
    <style>
        body {
            background-color: #F2F2F2;
            width: 100%;
            /* text-align: center; */
        }
        /* #main{
            width: 75.1%;
            margin: 0 auto;
        } */
        .container {
            width: 1200px;
            line-height: 80px;
            background-color: white;
            border-radius: 2px;
            margin-top: 10px;
            padding: 30px 60px;
        }
        
        .input_title {
            text-align: right;
        }
        
        .input_title>span:first-of-type {
            color: red;
        }
        
        .input_title>span:last-of-type {
            text-align: justify;
            text-align-last: justify;
            display: inline-block;
            word-wrap:break-word;
            width: 80px;
        }
        
        .input_text,
        .drop_down {
            height: 45px;
            line-height: 45px;
            width: 100%;
        }
        
        input:focus{
            outline: red;
        }
        .input_text1{
            height: 160px;
            line-height: 20px;
            width: 100%;
        }

        .gender {
            margin-right: 20px;
            display: inline-block;
        }

        .tijiao,
        .quxiao {
            width: 125px;
            height: 45px;
            line-height: 36px;
            padding: 0;
            border: 0;
            border-radius: 2px;
        }
    
        .tijiao {
            /* 提交按钮 */
            background-color: #49A2E8;
            color: white;
        }
    
        .quxiao {
            /* 重置按钮 */
            color: #666666;
            background-color: white;
            border: black 1px solid;
        }
    </style>
</head>

<body>
    
    <div class="container">
        <h2>新增优惠券</h2>

        <!-- 优惠券类型 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>优惠券类型</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <select class="drop_down" id="yhqzt">
                    <option value="">请选择优惠券类型</option>
                    <option value="s">满减券</option>
                    <option value="s">直减券</option>
                </select>
            </div>
        </div>

        <!-- 优惠券名称 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>优惠券名称</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <input type="text" class="input_text" placeholder="2-10个字" id="yhqName">
            </div>
        </div>

        <!-- 优惠券面值 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>优惠券面值</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <div class="gender">
                    <input type="radio" name="xingbie" id="yhqXj">现金
                </div>
                <div class="input-group">
                    <input type="text" class="form-control input_text" placeholder="0.5-1000的数字" aria-describedby="basic-addon2" id="yhqXjY">
                    <span class="input-group-addon" id="basic-addon1">元</span>
                  </div>
                <div class="gender">
                    <input type="radio" name="xingbie" id="yhqZk">折扣
                </div>
                <div class="input-group">
                    <input type="text" class="form-control input_text" placeholder="1-9.9的数字" aria-describedby="basic-addon2" id="yhqZkZ">
                    <span class="input-group-addon" id="basic-addon2">折</span>
                  </div>
            </div>
        </div>

        <!-- 使用条件 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>使用条件</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <div class="gender">
                    <input type="radio" name="xingbie" id="yhqWxz">无限制
                </div>
                <div class="gender">
                    <input type="radio" name="xingbie" id="yhqM">满
                </div>
                <div class="input-group">
                    <input type="text" class="form-control input_text" placeholder="1-100000的数字" aria-describedby="basic-addon2">
                    <span class="input-group-addon" id="basic-addon3">可使用</span>
                  </div>
            </div>
        </div>

        <!-- 使用范围 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>使用范围</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <select class="drop_down" id="yhqFw">
                    <option value="s">全平台</option>
                    <option value="s">PC端</option>
                    <option value="s">移动端</option>
                </select>
            </div>
        </div>

        <!-- 有效时间 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>有效时间</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <div class="gender">
                    <input type="radio" name="xingbie" id="yhqRqfw">日期范围
                </div>
                <div class="input-group">
                    <input type="date" class="form-control input_text" placeholder="开始日期" aria-describedby="basic-addon2">
                    <input type="date" class="form-control input_text" placeholder="结束日期" aria-describedby="basic-addon2">
                    <!-- <span class="input-group-addon" id="basic-addon4">元</span> -->
                  </div>
                <div class="gender">
                    <input type="radio" name="xingbie" id="yhqGdts">固定天数
                </div>
                <div class="input-group">
                    <input type="text" class="form-control input_text" placeholder="领取后多少天内有效" aria-describedby="basic-addon2">
                    <span class="input-group-addon" id="basic-addon5">天</span>
                  </div>
            </div>
        </div>

        <!-- 发行量 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>发行量</span>
            </div>
            <div class="col-md-4 col-xs-4" style="text-align: center;height: 80px;padding-top: 20px;">
                <div class="input-group">
                    <input type="text" class="form-control input_text " placeholder="大于等于0的正整数，0为无限制" aria-describedby="basic-addon2" id="yhqFxl">
                    <span class="input-group-addon" id="basic-addon6">张</span>
                  </div>
            </div>
        </div>

        <!-- 每人限领 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>每人限领</span>
            </div>
            <div class="col-md-4 col-xs-4" style="text-align: center;height: 80px;padding-top: 20px;">
                <div class="input-group">
                    <input type="text" class="form-control input_text " placeholder="大于的正整数，不填写默认为1" aria-describedby="basic-addon2" value="1" id="yhqXl">
                    <span class="input-group-addon" id="basic-addon7">张</span>
                  </div>
            </div>
        </div>
        
        <!-- 备注信息 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span></span><span>备注信息</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <textarea type="text" class="input_text input_text1" placeholder=""  maxlength="200" id="bz"></textarea>
            </div>
        </div>

        <!-- 商品范围 -->
        <div class="row">
            <div class="col-md-2 col-xs-2 input_title">
                <span>*</span><span>商品范围</span>
            </div>
            <div class="col-md-4 col-xs-4">
                <div class="gender">
                    <input type="radio" name="xingbie" id="qbSp">全部商品
                </div>
                <div class="gender">
                    <input type="radio" name="xingbie" id="zdSp">指定商品
                </div>
            </div>
        </div>

        <!-- 按钮 -->
        <div class="row">
            <div class="col-md-2 col-xs-2">
            </div>
            <div class="col-md-5 col-xs-5 content_right">
                <button class="tijiao">提交</button>
                <button class="quxiao">取消</button>
            </div>
        </div>
    </div>



    <script>
        //提交
    $('.tijiao').on('click',function () {
        let ztVal = $("#yhqzt option:selected").text()
        let yhqNameVal = $("#yhqName").val()
        //优惠券面值类型
        let yhqXjtVal = $("#yhqXj").attr("checked")
        console.log(yhqXjtVal)
        let yhqZkVal = $("#yhqZk").attr("checked")
        //面值
        let yhqXjYVal = $("#yhqXjY").val()
        let yhqZkZVal = $("#yhqZkZ").val()
        //使用条件类型
        let yhqWzVal = $("#yhqWz").attr("checked")
        let yhqMVal = $("#yhqM").attr("checked")
        //使用条件值
        let yhqMYVal = $("#yhqMY").val()
        //使用范围
        let yhqFwVal = $("#yhqFw option:selected").val()
        //有效时间类型
        let yhqRqfwVal = $("#yhqRqfw").attr("checked")
        let yhqGdtsVal = $("#yhqGdts").attr("checked")
        //有效时间
        let yhqJsTimeVal = $("#yhqJsTime").val()
        let yhqTsTimeVal = $("#yhqTsTime").val()
        //发行量
        let yhqFxlVal = $("#yhqFxl").val()
        //每人限领
        let yhqXlVal = $("#yhqXl").val()
        //备注
        let bzVal = $("#bz").val()
        //商品范围
        let qbSpVal = $("#qbSp").attr("checked")
        let zdSpVal = $("#zdSp").attr("checked")

      
      // num: "10",//序号
      // youhuiquanName: "今日用0",//优惠券名称
      // mianzhi:"50",//面值
      // sytj:"双十一期间，购买电器类商品，满200元，可以抵扣20元",//使用条件
      // yxTime: "2021-12-25",//有效时间
      // faxingNum:"100",//发行量
      // youhuiquanleixing:"满减券"//优惠券类型
      // zhuangtai:"可使用",//当前状态

      let arr = []
      let a = youhuiquanData.length
      arr.push(
        {num:"101"+a,//序号
         youhuiquanName:yhqNameVal,//优惠券名称
         mianzhi:yhqXjYVal,//面值元
         sytj:yhqMYVal,//使用条件
         yxTime:yhqGdtsVal,//有效时间
         faxingNum:yhqFxlVal,//发行量
         youhuiquanleixing:ztVal,//优惠券类型
         zhuangtai:"可使用",//当前状态
         mianzhi1:yhqZkZVal,//面值折
         qsTxTime:yhqJsTimeVal,//有效起始时间
         meirenxianlin:yhqXlVal,//每人限领
         beizhu:bzVal//备注
      })
      console.log($("#yhqName").val())
      console.log(arr)
      if($("#yhqName").val() != ''){
        youhuiquanData = youhuiquanData.concat(arr)
        arr = []
        let b =youhuiquanData.length
        console.log(youhuiquanData.length)
        console.log(youhuiquanData)
        location.href = './youhuiquanliebiao.html'
        // window.open("./cuxiaoguanli.html")
        // window.location.href = "./cuxiaoguanli.html"
      }else if($("#yhqName").val() == ''){
        confirm('优惠券名称不能为空！')
      }
    //   location.href = './youhuiquanliebiao.html'
    })


    //取消
    $('.quxiao').on('click',function () {
      location.href = './youhuiquanliebiao.html'
    })
    </script>
</body>


</html>